import { IRequestHook, IResponseHook, IOptions, Ictr } from './types'
import { cacheHook } from './hooks/cache/index'
import { commonParametersHook } from './hooks/commonParameters'
import { debounceHook } from './hooks/debounce'
import { resultHandelHook } from './hooks/resultHandel'

interface IDefaultConfig {
  options: IOptions
  requestHooks: IRequestHook[]
  responseHooks: IResponseHook[]
  ctr: Ictr
}
/**默认配置 */
export const defaultConfig: IDefaultConfig = {
  options: {
    baseURL: '',
    timeout: 3000
  },
  requestHooks: [debounceHook, commonParametersHook, cacheHook].map((x) => x.request),
  responseHooks: [debounceHook, resultHandelHook, cacheHook].map((x) => x.response),
  ctr: {
    debounce: false,
    dataCache: false,
    cacheType: 'db',
    cacheExpire: 60 * 60 * 48,
    isOkTip: false,
    isErrorTip: true,
    isOrigina: false
  }
}
